﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "教学运行管理 - 考试安排 - 打印考试安排");
		
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		termId = event.getArg("TermID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");

		examId = event.getArg("EXID");
		examType = event.getArg("ExamType");
		examName="";
		if(examType eq "F"){
			examName="期末考试";
		}else if(examType eq "M"){
			examName="期中考试";
		}else if(examType eq "D"){
			examName="分散考试";
		}
		clsroomId = event.getArg("CRID");
		
		currentTab = event.getArg("TabID", "labClassroom");
		
		passArgs = structNew();
		
		structInsert(passArgs, "EXID", examId, true);
		
		/* 加载考试任务 */
		sql = "SELECT 
					t_course.course_name, 
					t_examtask.wid, 
					t_examtask.wdidx,
					t_examtask.cellidx, 
					t_examtask.examer_sum 
				FROM 
					t_examtask 
					INNER JOIN t_course ON t_course.cid = t_examtask.cid 
				WHERE 
					t_examtask.task_exid = :taskExid ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="taskExid", value=examId, cfsqltype="cf_sql_char" );
		
		rs_examTask = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT classroom FROM t_classroom WHERE cr_id = :classroomId"; 

		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="classroomId", value=clsroomId, cfsqltype="cf_sql_char" );
		
		rs_classRoom = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT 
					t_classroom.cr_id, 
					t_classroom.classroom, 
					t_classroom.sits_exam, 
					t_campus.campus_name, 
					t_building.b_name, 
					t_classroom.cr_floor, 
					t_classroom_type.cr_type_name, 
					(SELECT COUNT(*) FROM t_student_exam b WHERE b.task_exid = a.task_exid AND b.cr_id = t_clsroom_timetable.cr_id ) countForEx 
				FROM 
					t_clsroom_forexam a 
					INNER JOIN t_clsroom_timetable ON t_clsroom_timetable.crtime_id = a.crtime_id 
					INNER JOIN t_classroom ON t_classroom.cr_id = t_clsroom_timetable.cr_id 
					INNER JOIN t_campus ON t_campus.campus_id = t_classroom.campus_id 
					INNER JOIN t_building ON t_building.b_id = t_classroom.b_id 
					INNER JOIN t_classroom_type ON t_classroom_type.cr_type = t_classroom.cr_type 
				WHERE 
					a.task_exid = :examId 
				ORDER BY 
					t_campus.campus_name, 
					t_building.b_name, 
					t_classroom.cr_floor, 
					t_classroom.classroom "; 
		
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_varchar" );
		
		rs_room = queryObj.execute( sql=sql ).getResult();
		
		rs_student = queryNew("sitidx");
		
		if ( rs_classRoom.recordCount ) {
			
			sql = "SELECT 
						t_student_exam.sitidx, 
						t_student.stu_id, 
						t_student.stu_name, 
						t_student.stu_sex, 
						t_class.cls_name, 
						t_class.grade, 
						t_subject.sbj_short, 
						t_institute.institute_short 
					FROM 
						t_student_exam 
						INNER JOIN t_student ON t_student.stu_id = t_student_exam.stu_id 
						INNER JOIN t_class ON t_class.cls_id = t_student.cls_id 
						INNER JOIN t_subject ON t_subject.sbj_id = t_class.sbj_id 
						INNER JOIN t_institute ON t_institute.institute_id = t_subject.institute_id 
					WHERE 
						t_student_exam.task_exid = :examId 
						AND 
						t_student_exam.cr_id = :clsroomId 
					ORDER BY 
						t_student_exam.sitidx "; 
			
			queryObj = new query( datasource=application.dnsSlave ); 
			queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
			queryObj.addParam( name="clsroomId", value=clsroomId, cfsqltype="cf_sql_char" );
			
			rs_student = queryObj.execute( sql=sql ).getResult(); 
		
		}
		
		if ( rs_student.recordCount ) {
			currentTab = event.getArg("TabID", "labStudent");
		}


	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
			<cfif examType eq "F"><a class="uiButton" href="<cfoutput>#buildURL('examArrange')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">期末考试安排</span></a></cfif>
			<cfif examType eq "M"><a class="uiButton" href="<cfoutput>#buildURL('examMidArrange')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">期中考试安排</span></a></cfif>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>《<cfoutput>#rs_examTask.course_name#</cfoutput>》 - 考试相关材料
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labClassroom">class="active"</cfif> id="labClassroom" tabTarget="Classroom"><cfoutput>#examName#</cfoutput>考场分布</span>
						<cfif rs_student.recordCount>
							<span <cfif currentTab eq "labStudent">class="active"</cfif> id="labStudent" tabTarget="Student"><cfoutput>#examName#</cfoutput>考场名单</span>
						</cfif>
					</div>
				</div>
				
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Classroom" class="tabContent">
					
					<div class="noticeBlock">
						<div class="operation">
						<cfset structInsert(passArgs, "ExamType", examType, true) />
	   						<a class="uiButton" target="_blank" href="<cfoutput>#buildURL('examPrintMakeTestPaper', passArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印制卷单</span></a>
							<a class="uiButton" target="_blank" href="<cfoutput>#buildURL('examPrintTestPaster', passArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印试卷贴</span></a>
							<a class="uiButton" target="_blank" href="<cfoutput>#buildURL('examPrintSitMap', passArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印座次表</span></a>
							<a class="uiButton" target="_blank" href="<cfoutput>#buildURL('examPrintSignature', passArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印签到单</span></a>
							<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('examStudentDownloadExcel', passArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载考场名单</span></a>
						</div>
						<h3>《<cfoutput>#rs_examTask.course_name#</cfoutput>》 考场设置</h3>
						<p>
							<span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期<cfoutput>#examName#</cfoutput>安排.
							该门课程考试计划安排于 <em><cfoutput>#rs_examTask.wid#</cfoutput></em> 周,
							考试时间: <cfoutput>#mathAdvice.convertWeekDayToChinese( rs_examTask.wdidx )#</cfoutput><cfoutput>#mathAdvice.convertExamIdxToChinese( rs_examTask.cellidx )#</cfoutput>, 
							计划有<em><cfoutput>#rs_examTask.examer_sum#</cfoutput></em>人需要安排考试.
						</p>
					</div>
					
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="18"></td>
								<td>教室</td>
								<td width="50">校区</td>
								<td width="150">教学楼</td>
								<td width="50">楼层</td>
								<td width="100">教室类别</td>
								<td width="80">考场座位</td>
								<td width="18"></td>
							</tr>
						</thead>
						<tbody>
							<cfset row = 0 />
                            <cfloop query="rs_room">
								<cfset row++ />
								<cfset structInsert(passArgs, "CRID", rs_room.cr_id, true) />
								<cfset structInsert(passArgs, "ExamType", examType, true) />
								<tr class="editRows">
									<td class="index"><cfoutput>#row#</cfoutput></td>
									<td><cfoutput>#rs_room.classroom#</cfoutput></td>
									<td><cfoutput>#rs_room.campus_name#</cfoutput></td>
									<td><cfoutput>#rs_room.b_name#</cfoutput></td>
									<td><cfoutput>#dictAdvice.getFloorString(rs_room.cr_floor)#</cfoutput></td>
									<td><cfoutput>#rs_room.cr_type_name#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_room.countForEx#</cfoutput> / <cfoutput>#rs_room.sits_exam#</cfoutput></span></td>
									<td><a title="查看考场名单" href="<cfoutput>#buildURL('examTaskPrint', passArgs)#</cfoutput>" class="stat examer"></a></td>
								</tr>
							</cfloop>
						</tbody>
					</table>
					
				</div>
				
				<cfif rs_student.recordCount>
					
					<cfset structInsert(passArgs, "CRID", clsroomId, true) />
					
					<div id="Student" class="tabContent">
						
						<div class="noticeBlock">
							
							<div class="operation">
								<a class="uiButton" target="_blank" href="<cfoutput>#buildURL('examPrintSitMapByRoom', passArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印座次表</span></a>
								<a class="uiButton" target="_blank" href="<cfoutput>#buildURL('examPrintSignatureByRoom', passArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印考生签到单</span></a>
							</div>
						


							<h3>《<cfoutput>#rs_examTask.course_name#</cfoutput>》 <cfoutput>#rs_classRoom.classroom#</cfoutput>考场名单</h3>
							<p>
								<span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期期末考试安排.
								该门课程考试计划安排于 <em><cfoutput>#rs_examTask.wid#</cfoutput></em> 周,
								考试时间: <cfoutput>#mathAdvice.convertWeekDayToChinese( rs_examTask.wdidx )#</cfoutput><cfoutput>#mathAdvice.convertExamIdxToChinese( rs_examTask.cellidx )#</cfoutput>, 
								计划有<em><cfoutput>#rs_examTask.examer_sum#</cfoutput></em>人需要安排考试.
							</p>
						</div>
						
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="25">座次</td>
									<td>学号</td>
									<td>姓名</td>
									<td>性别</td>
									<td>班级</td>
									<td>专业年级</td>
									<td>学院</td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_student">
									<tr class="editRows">
										<td class="index"><cfoutput>#rs_student.sitidx#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_student.stu_id#</cfoutput></span></td>
										<td><cfoutput>#rs_student.stu_name#</cfoutput></td>
										<td><cfif rs_student.stu_sex eq "1">男<cfelse>女</cfif></td>
										<td><cfoutput>#rs_student.cls_name#</cfoutput></td>
										<td><cfoutput>#rs_student.sbj_short#</cfoutput> <cfoutput>#rs_student.grade#</cfoutput>级</td>
										<td><cfoutput>#rs_student.institute_short#</cfoutput></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					</div>
				</cfif>
				
			</div>
		</li>
	</ul>
</div>